package com.bsoft.gol.editor.service.impl;

import com.alibaba.fastjson.JSONArray;

import com.bsoft.gol.editor.service.EditorHisModuleService;
import hcn.util.BaseResponse;
import com.bsoft.gol.editor.editor.request.ExamItemRequest;
import com.bsoft.gol.editor.editor.request.ExamreportRequest;
import com.bsoft.gol.editor.editor.request.LabreportRequest;
import com.bsoft.gol.editor.editor.request.UsageRequest;
import com.bsoft.gol.editor.editor.response.ExamItemResponse;
import com.bsoft.gol.editor.editor.response.ExamreportResponse;
import com.bsoft.gol.editor.editor.response.LabreportResponse;
import com.bsoft.gol.editor.editor.response.UsageResponse;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;
import com.bsoft.gol.editor.utils.JSONDateUtil;

import java.util.List;

/**
 * 表单编辑器 his 检查 检验 医嘱 报告到日
 * @author lxy
 * @date 2019/6/26
 */
@Service("editorHisModuleService")
public class EditorHisModuleServiceImpl implements EditorHisModuleService {

    private final static Logger log = LoggerFactory.getLogger(EditorHisModuleServiceImpl.class);


    /**
     * 检验结果
     *
     * @param request req
     * @return res
     */
    @Override
    public BaseResponse<List<LabreportResponse>> labreport(LabreportRequest request) {
        log.info("=入参=>>>" + request.toString() + "=====");
        String jsonContext = JSONDateUtil.readFile("labreport");
        List<LabreportResponse> responses = JSONArray.parseArray(jsonContext, LabreportResponse.class);
        BaseResponse<List<LabreportResponse>> baseResponse = new BaseResponse<>();
        baseResponse.setData(responses);
        return baseResponse;
    }

    /**
     * 检查结果
     *
     * @param request req
     * @return res
     */
    @Override
    public BaseResponse<List<ExamreportResponse>> examreport(ExamreportRequest request) {
        log.info("=入参=>>>" + request.toString() + "=====");
        String jsonContext = JSONDateUtil.readFile("examreport");
        List<ExamreportResponse> responses = JSONArray.parseArray(jsonContext, ExamreportResponse.class);
        BaseResponse<List<ExamreportResponse>> baseResponse = new BaseResponse<>();
        baseResponse.setData(responses);
        return baseResponse;
    }

    /**
     * 医嘱
     *
     * @param request req
     * @return res
     */
    @Override
    public BaseResponse<List<UsageResponse>> usage(UsageRequest request) {
        log.info("=入参=>>>" + request.toString() + "=====");
        String jsonContext = JSONDateUtil.readFile("usage");
        List<UsageResponse> responses = JSONArray.parseArray(jsonContext, UsageResponse.class);
        BaseResponse<List<UsageResponse>> baseResponse = new BaseResponse<>();
        baseResponse.setData(responses);
        return baseResponse;
    }

    /**
     * 检验指标项
     *
     * @param request req
     * @return res
     */
    @Override
    public BaseResponse<List<ExamItemResponse>> examImport(ExamItemRequest request) {
        log.info("=入参=>>>" + request.toString() + "=====");
        String jsonContext = JSONDateUtil.readFile("examImport");
        List<ExamItemResponse> responses = JSONArray.parseArray(jsonContext, ExamItemResponse.class);
        BaseResponse<List<ExamItemResponse>> baseResponse = new BaseResponse<>();
        baseResponse.setData(responses);
        return baseResponse;
    }
}
